<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <ui:remove><h:outputText value="#{bundle.ListAtoLegalTitle}"></h:outputText></ui:remove>
        </ui:define>
        <ui:define name="body">

            <p:growl id="messages" life="3000" />

            <h:panelGroup id="messagePanel" styleClass="ajustaListaMensagemErro"  layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="list"/>
            </h:panelGroup>

            <div align="center">
                <p:panel header="#{bundle.ListAtoLegalTitle}" style="width: 70%;" >                   

                    <p:dataTable id="tbl" value="#{atoLegalController.lista}" var="item"  paginator="true" rows="#{bundle.rows}" pageLinks="5" widgetVar="AtoLegalTable"
                                 currentPageReportTemplate="#{bundle.currentPageReportTemplateAtoLegal}"  paginatorTemplate="#{bundle.paginatorTemplate}"
                                 rowsPerPageTemplate="#{bundle.rowsPerPageTemplate}"  paginatorPosition="#{bundle.paginatorPosition}" emptyMessage="#{bundle.ListAtoLegalEmpty}" 
                                 rowKey="#{item.aleId}" selection="#{atoLegalController.selectedAtoLegal}" selectionMode="single"
                                 filteredValue="#{atoLegalController.lista}" styleClass="mystyle"  >

                        <p:column style="width: 5%; text-align: right;" sortBy="#{item.aleNumero}" filterBy="#{item.aleNumero}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListAtoLegalTitle_aleNumero}"/>
                            </f:facet>
                            <h:outputText value="#{item.aleNumero}" />
                        </p:column>

                        <p:column style="width: 5%; text-align: center;" sortBy="#{item.aleAno}" filterBy="#{item.aleAno}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListAtoLegalTitle_aleAno}"/>
                            </f:facet>
                            <h:outputText value="#{item.aleAno}" />
                        </p:column>

                        <p:column style="width: 25%;" sortBy="#{item.aleTalId.labelTipoAtoLegal}" filterMatchMode="contains" filterBy="#{item.aleTalId.labelTipoAtoLegal}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListAtoLegalTitle_aleTalId}"/>
                            </f:facet>
                            <h:outputText value="#{item.aleTalId.labelTipoAtoLegal}"/>
                        </p:column>

                        <p:column style="width: 5%; text-align: center;" sortBy="#{item.aleDt}" filterBy="#{item.aleDt}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListAtoLegalTitle_aleDt}"/>
                            </f:facet>
                            <h:outputText value="#{item.aleDt}">
                                <f:convertDateTime pattern="dd/MM/yyyy" />
                            </h:outputText>
                        </p:column>                       

                        <p:column style="width: 5%; text-align: center;" sortBy="#{item.statusAtoLegal}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListAtoLegalTitle_aleStatus}"/>
                            </f:facet>
                            <h:outputText value="#{item.statusAtoLegal}"/>
                        </p:column>

                        <p:column style="width: 3%" exportable="false">
                            <div class="cabecalho">
                                <div class="imagem">
                                    <p:commandLink update=":formList:displayView" oncomplete="AtoLegalDialogView.show()" onerror="AtoLegalDialogView.hide();" title="#{bundle.MsgVisualizar}" styleClass="ui-icon ui-icon-search">
                                        <f:setPropertyActionListener value="#{item}" 
                                                                     target="#{atoLegalController.selectedAtoLegal}" />
                                    </p:commandLink>
                                </div>                 
                                <div class="titulo">
                                    <p:commandLink ajax="false"  action="#{atoLegalController.prepareEdit}" rendered="#{!autenticadorController.loginVisualizador}" title="#{bundle.ListAtoLegalEditLink}" styleClass="ui-icon ui-icon-pencil" >
                                        <f:setPropertyActionListener value="#{item}" 
                                                                     target="#{atoLegalController.selectedAtoLegal}" />
                                    </p:commandLink>
                                </div>
                            </div>                     
                        </p:column>

                        <f:facet name="footer">                            
                            <p:commandButton id="createCommand" rendered="#{!autenticadorController.loginVisualizador}" ajax="false" icon="#{bundle.icone_documento}" action="#{atoLegalController.prepareCreate}" value="#{bundle.ListAtoLegalCreateLink}"/>
                            <p:commandButton id="viewCommand"  value="#{bundle.MsgVisualizar}" icon="#{bundle.icone_pesquisa}"  update=":formList:displayView" oncomplete="AtoLegalDialogView.show()" actionListener="#{atoLegalController.prepareView}" />
                            <p:commandButton id="editCommand" ajax="false" action="#{atoLegalController.prepareEdit}" value="#{bundle.ListAtoLegalEditLink}" icon="#{bundle.icone_pencil}" rendered="#{!autenticadorController.loginVisualizador}"/>
                            <p:commandButton id="deleteCommand" ajax="false" rendered="#{autenticadorController.loginAdmin}" onclick="confirmationDestroy.show();" value="#{bundle.ListAtoLegalDestroyLink}" type="button" icon="#{bundle.icone_lixeira}" />

                            <p:commandButton id="excelExportAll" ajax="false" value="#{bundle.excelExportAll}" icon="#{bundle.icone_script}">
                                <p:dataExporter type="xls" target="tbl" fileName="#{bundle.excelExportAllFileName_AtoLegal}"  postProcessor="#{atoLegalController.postProcessorXLS}"/>
                            </p:commandButton>
                            <p:commandButton id="excelExportPagAtual" ajax="false" value="#{bundle.excelExportPagAtual}" icon="#{bundle.icone_calculadora}">
                                <p:dataExporter type="xls" target="tbl" fileName="#{bundle.excelExportPagAtualFileName_AtoLegal}" pageOnly="true"  postProcessor="#{atoLegalController.postProcessorXLS}"/>
                            </p:commandButton>
                        </f:facet>
                    </p:dataTable>
                </p:panel>
            </div>
            <p:confirmDialog id="confirmDestroy" message="#{bundle.MsgConfirmDestroy_message}" header="#{bundle.MsgConfirmDestroy_header}" severity="alert" widgetVar="confirmationDestroy">
                <p:commandButton id="confirm" ajax="false" value="#{bundle.MsgDialog_confirmar}"  oncomplete="confirmationDestroy.hide(); #{atoLegalController.prepareList}" icon="#{bundle.icone_listar}" action="#{atoLegalController.destroy}" update="tbl"/>
                <p:commandButton id="decline"  value="#{bundle.MsgDialog_cancelar}" update="messages" onclick="confirmationDestroy.hide();" type="button"/>

            </p:confirmDialog>

            <p:dialog id="dialogView" header="#{bundle.AtoLegalDialogView_header}" widgetVar="AtoLegalDialogView" resizable="false" modal="true"
                      width="500" >

                <h:panelGrid id="displayView" columns="2" cellpadding="4">                          

                    <h:outputText value="#{bundle.ViewAtoLegalLabel_aleId}"/>
                    <h:outputText value="#{atoLegalController.selected.aleId}" title="#{bundle.ViewAtoLegalTitle_aleId}"/>

                    <h:outputText value="#{bundle.ViewAtoLegalLabel_aleNumero}"/>
                    <h:panelGroup>
                        <h:outputText value="#{atoLegalController.selected.aleNumero}"  title="#{bundle.ViewAtoLegalTitle_aleNumero}"/>

                        <h:outputText value="#{bundle.ViewAtoLegalLabel_aleAno}"/>
                        <h:outputText value="#{atoLegalController.selected.aleAno}" title="#{bundle.ViewAtoLegalTitle_aleAno}"/>
                    </h:panelGroup>
                    
                    <h:outputText value="#{bundle.ViewAtoLegalLabel_aleTalId}"/>
                    <h:outputText value="#{atoLegalController.selected.aleTalId.labelTipoAtoLegal}" title="#{bundle.ViewAtoLegalTitle_aleTalId}"/>  
                    <h:outputText value="#{bundle.ViewAtoLegalLabel_aleDt}"/>
                    <h:outputText value="#{atoLegalController.selected.aleDt}" title="#{bundle.ViewAtoLegalTitle_aleDt}">
                        <f:convertDateTime pattern="#{bundle.patternApp}" timeZone="#{filterSearchController.timeZone}"/>
                    </h:outputText>       
                    <h:outputText value="#{bundle.ViewAtoLegalLabel_aleStatus}"/>
                    <h:outputText value="#{atoLegalController.selected.statusAtoLegal}" title="#{bundle.ViewAtoLegalTitle_aleStatus}"/> 

                    <h:outputLabel value="#{bundle.createBy}" for="nomeCriador" rendered="#{not empty atoLegalController.selected.historicoCriacao.nomeUsuario}"/>
                    <h:outputText id="nomeCriador" value="#{atoLegalController.selected.historicoCriacao.nomeUsuario}" rendered="#{not empty atoLegalController.selected.historicoCriacao.nomeUsuario}"/>
                    <h:outputLabel value="#{bundle.createDate}" for="dataCriacao" rendered="#{not empty atoLegalController.selected.historicoCriacao.dataHora}"/>
                    <h:outputText id="dataCriacao" value="#{atoLegalController.selected.historicoCriacao.dataHora}" rendered="#{not empty atoLegalController.selected.historicoCriacao.dataHora}"/>     
                    <h:outputLabel value="#{bundle.updateBy}" for="nomeAlterador" rendered="#{not empty atoLegalController.selected.historicoAlteracao.nomeUsuario}"/>
                    <h:outputText id="nomeAlterador" value="#{atoLegalController.selected.historicoAlteracao.nomeUsuario}" rendered="#{not empty atoLegalController.selected.historicoAlteracao.nomeUsuario}"/>
                    <h:outputLabel value="#{bundle.updateDate}" for="dataAlteracao" rendered="#{not empty atoLegalController.selected.historicoAlteracao.dataHora}"/>
                    <h:outputText id="dataAlteracao" value="#{atoLegalController.selected.historicoAlteracao.dataHora}" rendered="#{not empty atoLegalController.selected.historicoAlteracao.dataHora}" />


                </h:panelGrid>
            </p:dialog>              
        </ui:define>
    </ui:composition>

</html>
